package com.liuf.di.controller;

import com.liuf.di.common.CommonResponse;
import com.liuf.di.configuration.kettle.KettleInitFactory;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.pentaho.di.repository.Repository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @program: spring-cloud-liuf-master
 * @description: 集群管理
 * @author: Mr.Liu
 * @create: 2018-09-19 18:10
 * @码云： https://gitee.com/www.jiandan.com
 **/
@Api(value = "/api/slave",description = "集群管理API")
@RestController
@RequestMapping(value = "/api/slave")
public class SlaveController {

    private Repository repository;

    @Autowired
    private KettleInitFactory kettleInitFactory;

    Map<String,Object> params = null;

    @ApiOperation(value = "获取集群列表")
    @GetMapping(value = "/findSlave")
    public List<Object> findSlave(@ApiParam(value = "分页参数-页数")@RequestParam(name = "pageNum", defaultValue = "0") int pageNum,
                                 @ApiParam(value = "分页参数-条数")@RequestParam(name = "pageSize", defaultValue = "10") int pageSize){
        params = new HashMap<>();
        params.put("pageNum",pageNum);
        params.put("pageSize",pageSize);
        return null;
    }


    @ApiOperation(value = "获取单一集群节点")
    @GetMapping(value = "/database/{id}")
    public CommonResponse getdatabase(@ApiParam(value = "主键ID")@PathVariable long id, HttpServletRequest request, HttpServletResponse response) throws Exception{
        return null;
    }

    @ApiOperation(value = "存储与修改集群节点")
    @PostMapping(value = "/database/saveOrUpdate")
    public CommonResponse save(@ApiParam(value = "数据源基础信息")@RequestBody Map<String,String> params,HttpServletRequest request,HttpServletResponse response)throws Exception{
        return null;
    }

    @ApiOperation(value = "删除集群节点")
    @DeleteMapping(value = "/database/delete/{name}")
    public CommonResponse delete(@ApiParam(value = "元数据名称") @PathVariable String name,HttpServletRequest request,HttpServletResponse response)throws Exception{
        return null;
    }
}
